package com.kt.uokos.yimo.wx.controller;

import com.kt.uokos.yimo.anno.validator.Order;
import com.kt.uokos.yimo.anno.validator.Sort;
import com.kt.uokos.yimo.dao.Issue;
import com.kt.uokos.yimo.service.IssueService;
import com.kt.uokos.yimo.util.ResponseUtil;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @description: TODO
 * @className: WxIssueController.java
 * @author: Kang Hao
 * @date: 2022/4/25 16:46
 **/

@RestController
@RequestMapping("/wx/issue")
public class WxIssueController {

    @Resource
    private IssueService issueService;


    @GetMapping("/list")
    public Object list(String question,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer size,
                       @Sort @RequestParam(defaultValue = "add_time") String sort,
                       @Order @RequestParam(defaultValue = "desc") String order){

        List<Issue> issues = issueService.querySelective(question, page, size, sort, order);
        return ResponseUtil.okList(issues);
    }


}
